package com.maxd.modules.selfshop.prize.controller;

import com.maxd.adapter.IgnoreSecurity;
import com.maxd.error.Result;
import com.maxd.modules.selfshop.prize.entity.SelfPrizeUser;
import com.maxd.modules.selfshop.prize.service.SelfPrizeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城抽奖记录",tags={"自营商城抽奖记录"})
@RequestMapping(value = "/selfPrizeUser")
public class SelfPrizeUserController {
    @Autowired
    private SelfPrizeUserService service;

    @IgnoreSecurity
    @GetMapping("/list")
    @ApiOperation("列表")
    public Result findAll(Integer page, Integer size, @RequestParam(required = false) String nickName) {
        return service.findAll(page, size, nickName);
    }

    @IgnoreSecurity
    @GetMapping("/userList")
    @ApiOperation("用户端列表")
    public Result userList(Integer page, Integer size, Long userId) {
        return service.userList(page, size, userId);
    }

    @IgnoreSecurity
    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @PostMapping("/save")
    @ApiOperation("添加")
    public Result saveBody(@RequestBody SelfPrizeUser entity) {
        return service.saveBody(entity);
    }

    @PostMapping("/update")
    @ApiOperation("修改")
    public Result updateBody(@RequestBody SelfPrizeUser entity) {
        return service.updateBody(entity);
    }


    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(Long id) {
        return service.delete(id);
    }

    @IgnoreSecurity
    @GetMapping("/checkNumber")
    @ApiOperation("今日剩余抽奖次数")
    public Result checkNumber(Long prizeRuleId, Long userId) {
        return service.checkNumber(prizeRuleId, userId);
    }

}
